namespace etcetera.Mvc.UI.Toolbar
{
    public class ToolbarRefreshButton : ToolbarButton
    {
        private bool _reset;

        public ToolbarRefreshButton(bool reset, string linkTitle, string buttonClass) : base(linkTitle, string.Empty, buttonClass)
        {
            _reset = reset;
        }

        public override string GetValue()
        {
            // Set the current URL
            PagerToolStrip toolStrip = (PagerToolStrip)Toolbar.ToolStrip;
            int page = _reset ? 1 : toolStrip.CurrentPage;
            ActionUrl = toolStrip.GetPagingUrl(page);

            return base.GetValue();
        }
    }
}